import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class MyThread {

    static class MyTask extends Thread implements Callable<String> {

        public void run(){
            System.out.println("hello");
            try {
                this.wait();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        @Override
        public String call() throws Exception {
            return "test";
        }
    }



    public static void main(String[] args) throws ExecutionException, InterruptedException {

        MyTask task = new MyTask();
        task.start();
        FutureTask<String> futureTask = new FutureTask<>(new MyTask());
        new Thread(futureTask).start();
        String result = futureTask.get();
        System.out.println(result);

    }

}
